//
//  SignViewController.m
//  EMMApp
//
//  Created by Mac on 16/5/18.
//  Copyright © 2016年 YiXun. All rights reserved.
//

#import "SignViewController.h"
#import "SignDetailsViewController.h"
#import "KnowCell.h"
#import "GetSignedListApi.h"
#import "AddNewSignViewController.h"
@interface SignViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *knowTableView;
@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, assign) int currentPageSize;// 当前页码
@property (nonatomic, strong) UILabel *jlLabel; //当前没有记录
@property (nonatomic, strong) GetSignedList *getSignedList;

@property (nonatomic, strong) NSString *khyxString;

@property (nonatomic, strong) NSString *isActual;

@end

@implementation SignViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatNavigationController];
    _khyxString = _getCustomerDetail.intentionLevel;
    if ([_khyxString isEqualToString:@"A"]) {
        _isActual = @"0";
    }
    self.view.backgroundColor = [UIColor colorFromHexCode:@"#f5f5f5"];
    [self creathtTableView];
    _jlLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 300, EMM_WIDTH, 20)];
    _jlLabel.textAlignment = NSTextAlignmentCenter;
    _jlLabel.text = @"当前没有记录";
    _jlLabel.font = [UIFont systemFontOfSize:16];
    _jlLabel.hidden = YES;
    [self.view addSubview:_jlLabel];
    [self.phonBtn addTarget:self action:@selector(phoneSDetailsbtn:) forControlEvents:UIControlEventTouchUpInside];
    //创建通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tongzhi:) name:@"SignVCIntentionLevel" object:nil];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    _dataArr = [[NSMutableArray alloc] init];
    [self.knowTableView.mj_header beginRefreshing];
}

#pragma mark - 初始化
- (void)creathtTableView {
    _knowTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 50.5, EMM_WIDTH, EMM_HEIGHT-50.5-SafeAreaTopHeight) style:UITableViewStylePlain];
    _knowTableView.delegate = self;
    _knowTableView.dataSource = self;
    _knowTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _knowTableView.showsVerticalScrollIndicator = NO;
    _knowTableView.backgroundColor = [UIColor colorFromHexCode:@"#f5f5f5"];
    [self.view addSubview:_knowTableView];
    
    self.knowTableView.mj_header= [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [self loadNewData];
        [self.knowTableView.mj_header endRefreshing];
    }];
    self.knowTableView.mj_header.automaticallyChangeAlpha = YES;
    self.knowTableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
        [self loadMoreData];
        [self.knowTableView.mj_footer endRefreshing];
    }];
    
    
}



- (void)creatNavigationController {
    [self updateNavBar];
    self.navigationItem.title = @"签约列表";
//    [self configLeftBtn];

    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setFrame:CGRectMake(0, 0, 54 ,44)];
    [backBtn addTarget:self
                action:@selector(NewbackToPreviousPage:)
      forControlEvents:UIControlEventTouchUpInside];
    [backBtn setBackgroundColor:[UIColor clearColor]];
    [backBtn setImage:[UIImage imageNamed:@"ico_back"] forState:UIControlStateNormal];
    backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    if (EMM_WIDTH <= 320) {
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
    }else if (EMM_WIDTH > 375){
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
    }else{
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
    }    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];

    
    UIBarButtonItem *rightItme = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"icon_jia"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(KnowRightClick:)];
    NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
    NSString *isAddSigned =[userdf objectForKey:@"isAddSigned"];
    if ([isAddSigned isEqualToString:@"1"]) {
        [self.navigationItem setRightBarButtonItem:rightItme];
    }
    [self.navigationItem setRightBarButtonItem:rightItme];
}

- (void)NewbackToPreviousPage:(id) send {
    if (_newCustomersBlock) {
        _newCustomersBlock();
    }
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)KnowRightClick:(UIButton *)btn  {
    NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
    NSString *necessary = [userdf objectForKey:@"necessary"];
    if ([necessary isEqualToString:@"1"]) {
        if ([_khyxString isEqualToString:@"A"]) {
            if ([_isActual isEqualToString:@"0"]) {
                AddNewSignViewController *nvc = [[AddNewSignViewController alloc] init];
                nvc.customerId = self.customerId;
                nvc.isAdd = YES;
                nvc.paymentMethod = self.paymentMethod;
                nvc.floorType = @"0";
                nvc.busReturnType = @"0";
                nvc.konString = @"0";
                NSMutableArray *arr = [[NSMutableArray alloc] init];
                nvc.jJRDataArr = arr;
                [self.navigationController pushViewController:nvc animated:YES];
            }else {
                [self creatIsLVneed];
            }
        }else {
            [self creatIsLVneed];
        }
    }else {
        AddNewSignViewController *nvc = [[AddNewSignViewController alloc] init];
        nvc.customerId = self.customerId;
        nvc.isAdd = YES;
        nvc.paymentMethod = self.paymentMethod;
        nvc.floorType = @"0";
        nvc.busReturnType = @"0";
        nvc.konString = @"0";
        NSMutableArray *arr = [[NSMutableArray alloc] init];
        nvc.jJRDataArr = arr;
        [self.navigationController pushViewController:nvc animated:YES];
    }
    
}

- (void)creatIsLVneed {
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
    //修改title
    NSString *titleString = [NSString stringWithFormat:@"签约要求客户意向等级必须为【A】级以上"];
    NSMutableAttributedString *alertControllerStr = [[NSMutableAttributedString alloc] initWithString:titleString];
    [alertControllerStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorFromHexCode:@"#333333"] range:NSMakeRange(0, titleString.length)];
    [alertControllerStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, titleString.length)];
    [alertController setValue:alertControllerStr forKey:@"attributedTitle"];
    
    //修改message
    NSString *str = [NSString stringWithFormat:@"请完善客户信息"];
    NSMutableAttributedString *alertControllerMessageStr = [[NSMutableAttributedString alloc] initWithString:str];
    [alertControllerMessageStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorFromHexCode:@"#333333"] range:NSMakeRange(0, str.length)];
    [alertControllerMessageStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, str.length)];
    [alertController setValue:alertControllerMessageStr forKey:@"attributedMessage"];
    
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
        
    }];
    
    [cancelAction setValue:[UIColor colorFromHexCode:@"#333333"] forKey:@"titleTextColor"];
    
    UIAlertAction *otherAction = [UIAlertAction actionWithTitle:@"完善信息" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
        NewCustomerWebViewController *fvc = [[NewCustomerWebViewController alloc] init];
        fvc.isflg = YES;
//        fvc.getCustomerDetail = _getCustomerDetail;
        fvc.customerId = self.customerId;
//        fvc.isTransaction = @"1";
//        fvc.transactionType = @"2";
        [self.navigationController pushViewController:fvc animated:YES];
    }];
    [otherAction setValue:[UIColor colorFromHexCode:@"#F87242"] forKey:@"titleTextColor"];
    
    [alertController addAction:cancelAction];
    [alertController addAction:otherAction];
    [self presentViewController:alertController animated:YES completion:nil];
}


#pragma mark 下拉刷新数据
- (void)loadNewData {
    [_dataArr removeAllObjects];
    _currentPageSize = 1;
    [self postGetSubscribeListApiCurrentPageSize:_currentPageSize];
    
}

#pragma mark 上拉加载更多数据
- (void)loadMoreData {
    
    _currentPageSize = _currentPageSize + 1;
    [self postGetSubscribeListApiCurrentPageSize:_currentPageSize];
    
}

#pragma mark - 结束刷新
- (void)endRefreshing {
    [self.knowTableView.mj_footer endRefreshing];
    [self.knowTableView.mj_header endRefreshing];
}

#pragma mark -
- (void)postGetSubscribeListApiCurrentPageSize:(int)currentPageSize {
    
    [self showHud:@"正在加载请稍等..."];
    GetSignedListApi *api = [[GetSignedListApi alloc] initWithCustomerId:self.customerId pageNumber:currentPageSize pageSize:10];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        GetSignedListApi *result = (GetSignedListApi *)request;
        if (result.isSuccess) {
            GetSignedList *get = result.resultData;
            _getSignedList = get;
            for (SignedList *list in get.signedList) {
                [_dataArr addObject:list];
            }
            if (_dataArr.count > 0) {
                
                _jlLabel.hidden = YES;
            }else {
                
                _jlLabel.hidden = NO;
            }
            [self upTitleInitWith];
            
        } else {
//            [self showToast:result.resultData.errorMsg];
            NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
            NSString *projectCode = [userdf objectForKey:@"projectCode"];
            if ([NSString isStringEmpty2:projectCode] == NO) {
                [self showToast:result.resultData.errorMsg];
            }
            
            /*
             提示语：账号权限发生变动，请重新登录
             code随机18位唯一码：108E65843mYuwqb01X
             //YUplf0wyU5vPVssLSG 对应的异地登录退出登录
             */
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
        [self hideHud];
        [self endRefreshing];
        [_knowTableView reloadData];
    } failure:^(YTKBaseRequest *request) {
        _knowTableView.hidden = YES;
        _jlLabel.hidden = NO;
        [self showToast:@"连接服务器失败，请检查网络！"];
        [self hideHud];
        [self endRefreshing];
    }];
}

- (void)upTitleInitWith {
    self.userNameLabel.text = _getSignedList.customerName;
    NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],};
    CGSize textSize = [_getSignedList.customerName boundingRectWithSize:self.view.frame.size options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;
    if (textSize.width > self.view.frame.size.width - 150) {
        self.nameWidthConst.constant = self.view.frame.size.width - 150;
        self.nameHeightConst.constant = 45;
    }else {
        self.nameWidthConst.constant = textSize.width + 10;
        self.nameHeightConst.constant = 25;
    }
    
//        if ([NSString isStringEmpty2:_getCustomerDetail.customerStar] == NO) {
//            if ([_getCustomerDetail.customerStar isEqualToString:@"是"]) {
//                self.customerStar.hidden = NO;
//            }else {
//                self.customerStar.hidden = YES;
//            }
//        }
        self.sexLabel.layer.masksToBounds = YES;
        self.sexLabel.layer.cornerRadius = 5;
        self.sexLabel.backgroundColor = [UIColor colorFromHexCode:@"#fe8d29"];
        self.sexLabel.text = _getCustomerDetail.customerSex;
        self.gradeLabel.layer.masksToBounds = YES;
        self.gradeLabel.layer.cornerRadius = 5;
        self.gradeLabel.text = _getCustomerDetail.intentionLevel;
        self.gradeLabel.backgroundColor = [UIColor colorFromHexCode:@"#FB5A3B"];
    self.phoneLabel.text = _getSignedList.customerPhone;
}


#pragma mark - UITableView代理

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 100;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellId = @"KnowCellId";
    KnowCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"KnowCell" owner:self options:nil] lastObject];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    cell.knoeLabel.backgroundColor = [UIColor colorFromHexCode:@"#7914F5"];
    cell.statusLabel.backgroundColor = [UIColor colorFromHexCode:@"#7914F5"];
    if (_dataArr.count > 0) {
        SignedList *list = [_dataArr objectAtIndex:indexPath.row];
        
        cell.knowItmerLabel.text = list.signedTime;
        cell.knowNameLabel.text = list.signedHouses;
        [cell setSubscribeHouses:list.recordBusiness] ;
        if ([NSString isStringEmpty2:list.signedHouses] == NO) {
            
        }else {
            cell.knowNameLabel.text = @"无房";
        }
        if ([list.auditStatus isEqualToString:@"待提交"]) {
            cell.knowIMageView.image = [UIImage imageNamed:@"icon_submit"];
        }else if ([list.auditStatus isEqualToString:@"审核中"]) {
            cell.knowIMageView.image = [UIImage imageNamed:@"icon_revie"];
        }else if ([list.auditStatus isEqualToString:@"已退回"]) {
            cell.knowIMageView.image = [UIImage imageNamed:@"icon_back"];
        }else if ([list.auditStatus isEqualToString:@"已通过"]) {
            cell.knowIMageView.image = [UIImage imageNamed:@"icon_sucss"];
        }
        if (([list.auditStatus isEqualToString:@"已退回"])||[list.recordBusiness isEqualToString:@"签约退房"]){
            cell.knoeLabel.backgroundColor = [UIColor colorFromHexCode:@"#AAAAAA"];
            cell.statusLabel.backgroundColor = [UIColor colorFromHexCode:@"#AAAAAA"];
        }
        
     
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (_dataArr.count > 0) {
        SignedList *list = [_dataArr objectAtIndex:indexPath.row];
        SignDetailsViewController *kvc = [[SignDetailsViewController alloc] init];
        kvc.signedId = list.signedId;
        kvc.getCustomerDetail = _getCustomerDetail;
        kvc.customerId = _customerId;
        kvc.isNot = YES;
        [self.navigationController pushViewController:kvc animated:YES];
    }
}

#pragma mark - 拨打电话
- (void)phoneSDetailsbtn:(UIButton *)sender {
//    NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
//    NSString *isPhoneInformation = [userdf objectForKey:@"isPhoneInformation"];
//    if ([NSString isStringEmpty2:isPhoneInformation] == NO) {
//        if ([isPhoneInformation isEqualToString:@"0"]) {
//            NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_getSignedList.customerPhone];
//            UIWebView * callWebview = [[UIWebView alloc] init];
//            [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
//            [self.view addSubview:callWebview];
//
//        }else if ([isPhoneInformation isEqualToString:@"1"]) {
//            [self postGetUserCallListApi];
//        }
//    }else {
//        NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_getSignedList.customerPhone];
//        UIWebView * callWebview = [[UIWebView alloc] init];
//        [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
//        [self.view addSubview:callWebview];
//    }
    [self postGetUserCallListApi];

}

#pragma maek - 电话平台调用方法

- (void)postGetUserCallListApi {
    [self showHudInWindow:@"正在加载中..."];
    GetUserCallListApi *api = [[GetUserCallListApi alloc] initWith];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        GetUserCallListApi *result = (GetUserCallListApi *)request;
        //请求成功
        if (result.isSuccess) {
            GetUserCallList *get = result.resultData;
            if ([NSString isStringEmpty2:get.isPhoneInformation] == NO) {
                if ([get.isPhoneInformation isEqualToString:@"0"]) {
                    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_getSignedList.customerPhone];
                    UIWebView * callWebview = [[UIWebView alloc] init];
                    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
                    [self.view addSubview:callWebview];
                }else {
                    UserCallMenuView *userListV = [[UserCallMenuView alloc] initWithFrame:CGRectMake(0, 0, EMM_WIDTH, EMM_HEIGHT) title:@"选择拨打号码" nameArr:get.userCallList];
                    userListV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
                    [[UIApplication sharedApplication].keyWindow addSubview:userListV];
                    __weak UserCallMenuView *weakMenuView = userListV;
                    [userListV setTouchUserCallMenuViewBlock:^(NSString *telePhone, NSString *telePhoneType) {
                        NSLog(@"%@-%@",telePhone,telePhoneType);
                        if ([NSString isStringEmpty2:telePhone] == NO) {
                            [self postGetCallBackApiTelePhoneString:telePhone];
                        }
                        [weakMenuView removeFromSuperview];
                    }];
                }
            }else {
                NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_getSignedList.customerPhone];
                UIWebView * callWebview = [[UIWebView alloc] init];
                [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
                [self.view addSubview:callWebview];
            }
        } else {
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
        [self hideHud];
    } failure:^(YTKBaseRequest *request) {
        [self showToast:@"连接服务器失败，请检查网络！"];
        [self hideHud];
    }];
}

- (void)postGetCallBackApiTelePhoneString:(NSString *)telePhoneString {
    
    GetCallBackApi *api = [[GetCallBackApi alloc] initWithCustomerId:self.customerId caller:telePhoneString called:_getSignedList.customerPhone terminalModel:@"0" terminalModelId:self.customerId];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        GetCallBackApi *result = (GetCallBackApi *)request;
        //请求成功
        if (result.isSuccess) {
            GetCallBack *get = result.resultData;
            FollowUpViewController *fvc = [[FollowUpViewController alloc] init];
            fvc.customerId = self.customerId;
            fvc.followId = get.followId;
            [self.navigationController pushViewController:fvc animated:YES];
        } else {
            NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
            NSString *projectCode = [userdf objectForKey:@"projectCode"];
            if ([NSString isStringEmpty2:projectCode] == NO) {
                [self showToast:result.resultData.errorMsg];
            }
            
            /*
             提示语：账号权限发生变动，请重新登录
             code随机18位唯一码：108E65843mYuwqb01X
             //YUplf0wyU5vPVssLSG 对应的异地登录退出登录
             */
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
        [self hideHud];
    } failure:^(YTKBaseRequest *request) {
        [self showToast:@"连接服务器失败，请检查网络！"];
        [self hideHud];
    }];
}

#pragma mark - 接受通知
- (void) tongzhi:(NSNotification *)notification{
    NSDictionary *dic = notification.userInfo;
    _khyxString = [dic objectForKey:@"intentionLevel"];
    _isActual = @"0";
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
